
package com.hex.ds.code.detection.config.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hex.ds.code.detection.config.dao.ConfigPathGitMapper;
import com.hex.ds.code.detection.config.model.ConfigPathGit;
import com.hex.ds.code.detection.config.service.ConfigPathGitService;
import com.hex.ds.code.detection.common.constants.CommonConstants;
import org.springframework.stereotype.Service;

import java.util.List;
 /**
  * @Package com.hex.ds.code.detection.script.config.service.impl
  * @ClassName ConfigPathGitServiceImpl
  * @Description git路径配置表
  * @Author le.zhang
  * @Date 2024/3/4 13:07
  * @Version v1.0
  **/
@Service
public class ConfigPathGitServiceImpl extends ServiceImpl<ConfigPathGitMapper, ConfigPathGit> implements
     ConfigPathGitService {

/**
 * @Method queryList
 * @Param page
 * @Param configPathGit
 * @Return com.baomidou.mybatisplus.extension.plugins.pagination.Page
 * @Description 分页查询返回Page对象
 * @Author le.zhang
 * @Date 2024/3/4 13:08
 * @Version V1.0
 */
    @Override
    public Page queryList(Page page, ConfigPathGit configPathGit) {
        LambdaQueryWrapper<ConfigPathGit> wrapper = beforeQuery(configPathGit);
//        wrapper.eq(ConfigPathGit::getDel,CommonConstants.STATUS_NORMAL);
        Page returnPage = this.baseMapper.selectPage(page, wrapper);
        return returnPage;
    }


/**
 * @Method beforeQuery
 * @Param configPathGit
 * @Return com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<com.hex.ds.code.detection.script.config.model.ConfigPathGit>
 * @Description  分页前置查询，通过gitpath模糊查
 * @Author le.zhang
 * @Date 2024/3/4 13:08
 * @Version V1.0
 */
    private LambdaQueryWrapper<ConfigPathGit> beforeQuery(ConfigPathGit configPathGit){
        LambdaQueryWrapper<ConfigPathGit> wrapper = Wrappers.lambdaQuery();
//        if (StrUtil.isNotBlank(configPathGit.getGitpath())) {
//            wrapper.like(ConfigPathGit::getGitpath, configPathGit.getGitpath());
//        }
        if (StrUtil.isNotBlank(configPathGit.getGitname())) {
            wrapper.like(ConfigPathGit::getGitname, configPathGit.getGitname());
        }
        return wrapper;
    }

/**
 * @Method queryListNoPage
 * @Param configPathGit
 * @Return java.util.List<com.hex.ds.code.detection.script.config.model.ConfigPathGit>
 * @Description 不分页查询
 * @Author le.zhang
 * @Date 2024/3/4 13:08
 * @Version V1.0
 */
    @Override
    public List<ConfigPathGit> queryListNoPage(ConfigPathGit configPathGit) {
        LambdaQueryWrapper<ConfigPathGit> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(StrUtil.isNotBlank(configPathGit.getGitpath()), ConfigPathGit::getGitpath, configPathGit.getGitpath());
        List<ConfigPathGit> configPathGitList = this.baseMapper.selectList(wrapper);
        return configPathGitList;
    }


}
